<?php

if (file_exists(INFUSIONS."buddys_system/locale/".$settings['locale'].".php")) {
	include INFUSIONS."buddys_system/locale/".$settings['locale'].".php";
} else {
	include INFUSIONS."buddys_system/locale/English.php";
}



openside($locale['mf06']);

$result = dbquery("SELECT * FROM ".DB_PREFIX."buddys
WHERE buddy_to = ".$userdata['user_id']." AND buddy_status != 0 AND buddy_status !=2");

$i = 0;
while($data = dbarray($result)){
$result_check = dbquery("SELECT * FROM ".DB_PREFIX."buddys
WHERE buddy_to = ".$data['buddy_from']." AND buddy_from = ".$userdata['user_id'].""); 
$data_check = dbarray($result_check);
if ($data_check['buddy_id'] != true) {
$i = $i+1; 
}} if ($i > 0) {$i = "<font color='red'>$i</font>";}


echo "<center><img src='".BASEDIR."images/ven.png' alt='' /> <a href='".INFUSIONS."buddys_system/buddys.php' class='side'>".$locale['mf07']."</a> ($i)</center><hr />";

$lastseen=time()-120; // 120 sek.

echo"<table border='0' cellpadding='0' cellspacing='1' width='100%'>\n";
$result=dbquery("SELECT * FROM ".DB_PREFIX."users WHERE user_lastvisit >=".$lastseen."");

while($data = dbarray($result)) {

$result_from=dbquery("SELECT * FROM ".DB_PREFIX."buddys WHERE
buddy_from = ".$userdata['user_id']." AND buddy_to = ".$data['user_id']."");
$data_from = dbarray($result_from);

$result_to=dbquery("SELECT * FROM ".DB_PREFIX."buddys WHERE
buddy_to = ".$userdata['user_id']." AND buddy_from = ".$data['user_id']."");
$data_to = dbarray($result_to);

if($data_to['buddy_id'] != "" AND $data_from['buddy_id'] != ""){

$bild = "<img src='".INFUSIONS."buddys_panel/images/mail.gif' border='0'>";
$datum = strftime("Last visit: Kl. %H:%M:%S ", $data['user_lastvisit']);

echo "<tr>
<td><a href='".BASEDIR."messages.php?msg_send=".$data['user_id']."' target='_parent'>$bild</a> <a href='".BASEDIR."profile.php?lookup=".$data['user_id']."' target='_parent' title='$datum'>".$data['user_name']."</a></td>
</tr>";

}

}

echo"</table>\n";
closeside();


?>